<?php
class News_Service_Navigation {
	
	private $_view = null;
	
	public function __construct() {
		if($this->_view === null) {
			$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
			if (null === $viewRenderer->view) {
				$viewRenderer->initView();
			}
			$view = $viewRenderer->view;
			$this->_view = $view;
		}
	}
	
	public function getContainer() {
		$container = array(
			array(
				'label' => $this->_view->translate('News'),
				'route' => 'news_index_index',
				'controller' => 'index',
				'module' => 'news',
				'action' => 'index',
				'pages' => array(
					
				)
			)
		);
		
		$news = Doctrine_Core::getTable('News_Model_News')->findAll();
		
		if($news->count() > 0) {
			foreach ($news as $key=>$n) {
				$container[0]['pages'][$key]['label'] = $n->Translation[$this->_view->LANG]->name;
				$container[0]['pages'][$key]['route'] = 'news_index_show';
				$container[0]['pages'][$key]['controller'] = 'index';
				$container[0]['pages'][$key]['module'] = 'news';
				$container[0]['pages'][$key]['action'] = 'show';
				$container[0]['pages'][$key]['params'] = array('id' => $n->id);
			}
		}
		
		return $container;
	}
}